import { createSlice } from '@reduxjs/toolkit'

export const city = createSlice({
  name: 'city',
  initialState: {
    start:'北京',
    end:'上海'
  },
  reducers: {
       exchange(state){
        let temp=state.start;
        state.start=state.end;
        state.end=temp
       },
       setcity(state,{payload:{type,city}}){
        state[type]=city
       }
  },
})

// Action creators are generated for each case reducer function
export const { exchange,setcity } = city.actions

export default city.reducer